﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace sign_recognition
{

    class ReadFile
    {

        public StreamReader reader;
        public String name;

        public ReadFile(String fileName)
        {
            this.name = fileName;
            reader = new StreamReader(this.name);

        }

        public Weights readWeights()
        {
           // Double[] weights = null;
            String line = "";
            Weights w = new Weights();
            String[] values = null;

            if ((line = reader.ReadLine()) != null)
            {
                values = line.Split(' ');
            }
            else {
                return null;
            }
            w.values = new Double[values.Count()-1];
            for (int i = 0; i < w.values.Count(); i++ )
            {
                w.values[i]=Double.Parse(values[i]);
            }
            w.output = values[w.values.Count()].Substring(1,1);

            return w;
        }
        public int getCategoriesAmount()
        {
            int categoriesCounter = 0;
            while(reader.ReadLine() != null){
                categoriesCounter++;
            }
            this.reader.Close();
            reader = new StreamReader(this.name);
            return categoriesCounter;

        }
        public void close()
        {
            this.reader.Close();
        }

    }
}
